<template>
	<view class="">
		<view class="alert">
			<u-modal v-model="shows" :show-title="false" :content="content" confirm-text="立即联系" cancel-text="我知道了"
				cancel-color="#333333" :show-cancel-button="true" confirm-color="#4DC0D9" @confirm="confirm"
				@cancel="cancel">
				<view class="slot-content">
					<rich-text :nodes="content"></rich-text>
				</view>
			</u-modal>
		</view>
		<view>
			<u-action-sheet :list="list" v-model="shall" border-radius="30" :safe-area-inset-bottom="true"
				@click="shallBorad"></u-action-sheet>
		</view>
	</view>
	<!-- <con-me :show="conShow" @Pshow="Pshow"></con-me> -->
</template>

<script>
	/**
	 * :show  展示组件
	 * @Pshow 父组件方法，子组件关闭通知父组件
	 */
	import {
		servicePhone
	} from '@/config/app.js'
	import register from '@/utils/register'
	export default {
		props: {
			show: {
				default: false,
				required: false
			}
		},
		name: "con-me",
		data() {
			return {
				//show: true,
				shall: false, //分享显示
				content: `暂无权限，请联系平台运营助理帮 您开通：${servicePhone}`,
				list: [{
					text: `当前电话号码是：${servicePhone}`,
					color: '#666666',
					fontSize: 30,
					// subText: '感谢您的点赞'
				}, {
					text: '呼叫',
					color: '#4DC0D9',
					fontSize: 32,
				}, {
					text: '复制号码',
					color: '#333333',
					fontSize: 32,
				}],
			};
		},
		computed: {
			shows: {
				get() {
					return this.show
				},
				set(val) {
					this.$emit('Pshow', val)
				}
			}
		},
		methods: {
			shallBorad(index) { //1呼叫  2复制号码
				if (index == 1) {
					this.makePhone()
				}
				if (index == 2) {
					this.Wxcopy()
				}
				//console.log(index);
			},
			confirm() { //立即联系
				this.shall = true
				//console.log('confirm');
			},
			cancel() { //我知道了
				this.$emit('Pshow', false)
				//console.log('cancel');
			},
			makePhone() { //打电话
				// this.$ww.makePhoneCall({
				// 	phoneNumber: `${servicePhone}` //仅为示例，并非真实的电话号码
				// })
				let a = document.createElement('a'); // 创建一个a节点插入的document
				let event = new MouseEvent('click') // 模拟鼠标click点击事件
				a.href = `tel:${servicePhone}`; // 将图片的src赋值给a节点的href
				a.dispatchEvent(event) //移除点击事件
				a.remove(); // 把创建的元素删除
			},
			async Wxcopy() { //复制
				await register(['setClipboardData'])
				let that = this
				this.$ww.setClipboardData({
					data: `${servicePhone}`,
					success(res) {
						this.$ww.getClipboardData({
							success(res) {
								alert(res)
								//console.log(res.data) // data
							}
						})
					}
				})
				this.$ww.getClipboardData({
					success(res) {
						alert(res)
						that.$u.toast('复制成功')
						//console.log(res.data)
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.alert {

		.slot-content {
			padding: 40rpx 36rpx 40rpx 36rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: bold;
			font-size: 32rpx;
			color: #333333;
			line-height: 48rpx;
			text-align: center;
		}
	}
</style>